import { Injectable } from '@nestjs/common';
import { JwtService } from '@nestjs/jwt';
import { UserService } from 'src/user/user.service';

@Injectable()
export class AuthService {
  constructor(
    private readonly userService: UserService,
    private jwtService: JwtService,
  ) {}
  createToken(payload: { id: number; username: string }) {
    const user = { email: payload.username, id: payload.id };
    const access_token = this.jwtService.sign(user);
    return {
      access_token,
      type: 'Bearer',
    };
  }
}
